#pragma once
#if _MSC_VER >=1600
#pragma execution_character_set("utf-8")
#endif

#include <QDialog>
//namespace Ui { class CDlgSetupADChan; };
#include "ui_CDlgSetupADChan.h"
#include "RefSpec.h"


enum DAQ_TYPE_CHAN { Inactive = 0, Control, Limit, Auxiliary };
enum DAQ_TYPE_COUPLING { AC = 0, DC, ICP };
enum DAQ_TYPE_TRX { Acc = 0, Force, Strain };
enum DAQ_TYPE_LOOP { No = 0, Yes };
const QStringList szlist_DAQ_TYPE_CHAN = { "Inactive", "Control", "Limit", "Auxiliary" };
const QStringList szlist_DAQ_TYPE_COUPLING = { "AC", "DC", "ICP" };
const QStringList szlist_DAQ_TYPE_TRX = { "Acc" , "Force", "Strain" };
const QStringList szlist_DAQ_TYPE_LOOP { "No", "Yes" };
#define szCombBoxFirstText  tr("To select...")
#define FILE_TYPE_ADCHAN "***ADCHAN***"

struct DAQ_ADCHAN
{
	int		nID			{ -1 };
	bool	bLoopChk	{ false };
	int		nRefIndex	{ -1 };
	std::string		szSensitivity;
	std::string		szRMSAbort;
	std::string		szUnits;
	DAQ_TYPE_CHAN	enTypeChan;
	DAQ_TYPE_TRX	enTypeTrx;
	DAQ_TYPE_COUPLING enCoupling;
};

class CDlgSetupADChan : public QDialog
{
	Q_OBJECT

public:
	CDlgSetupADChan(QWidget *parent = Q_NULLPTR);
	~CDlgSetupADChan();

	int m_nDAQADChan{ 8 };
	QList<REF_PSD> m_listRefPSD;

	QString m_szUnitsAcc;
	int m_nCtrl;
	QMap<int, DAQ_ADCHAN> m_mapADChan;

private:
	Ui::CDlgSetupADChan *ui;

	QStringList m_listRefPSDName;

private:
	void InitTableWidget(/*QTableWidget * pTable*/);
	bool ValidateChanTable();
	void UpdateChanTable();
	void RemoveEditWidget();

	void on_btnApply_clicked();
	void on_btnOK_clicked();
	void on_btnSaveTo_clicked();
	void on_btnLoadFrom_clicked();

	void on_tableADChan_cellClicked(int row, int column);
	void on_tableADChan_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousCol);

protected:
	void showEvent(QShowEvent *evt);

};

extern QMap<int, DAQ_ADCHAN> g_mapADChan;
